<?php

namespace app\store\controller\finance;

use app\store\controller\Controller;
use app\common\model\Finance as FinanceModel;

/**
 * 数据概况
 * Class Data
 * @package app\store\controller\statistics
 */
class Data extends Controller
{
    /* @var FinanceModel FinanceDataService 数据概况服务类 */
    private $financeModel;

    /**
     * 构造方法
     * @throws \app\common\exception\BaseException
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function _initialize()
    {
        parent::_initialize();
        $this->financeModel = new FinanceModel();
    }


    /**
     * 数据统计主页
     * @return mixed
     * @throws \think\Exception
     */
    public function index()
    {

        return $this->fetch('index', [
            // 数据概况
            'survey' => $this->getSurveyData(),
        ]);
    }


    /**
     * 数据概况API
     * @param null $startDate
     * @param null $endDate
     * @return array
     * @throws \think\Exception
     */
    public function survey($startDate = null, $endDate = null)
    {
        return $this->renderSuccess('', '',
            $this->getSurveyData($startDate, $endDate));
    }



    /**
     * 获取数据概况
     * @param $startDate
     * @param $endDate
     * @return array
     * @throws \think\Exception
     */
    public function getSurveyData($startDate = null, $endDate = null)
    {
        return [
            // 总流水
            'totalPay' => $this->financeModel->getTotalPay($startDate, $endDate),
            // 微信支付
            'wechatPay' => $this->financeModel->getWechatPay($startDate, $endDate),
            // 余额支付
            'moneyPay' => $this->financeModel->getMoneyPay($startDate, $endDate),
            //实收金额
//            'actualPay' => $this->financeModel->getActualPay($startDate, $endDate),
            //微信实收
            'wechatActualPay' => $this->financeModel->getWechatActualPay($startDate, $endDate),
            //余额实收
//            'moneyActualPay' => $this->financeModel->getMoneyActualPay($startDate, $endDate),
            //微信分红金额
            'bonusMoney' => $this->financeModel->getBonusMoney($startDate, $endDate),
            //分红余额
            'bonusOutMoney' => $this->financeModel->bonusOutMoney($startDate, $endDate),
            //分红未出局
            //'bonusMoneyNo' => $this->financeModel->getbonusMoneyNo($startDate, $endDate),
            //分红已出局
            //'bonusMoneyOut' => $this->financeModel->getbonusMoneyOut($startDate, $endDate),
            //分销金额
            'dealcerMoney' => $this->financeModel->getDealcerMoney($startDate, $endDate),
            //商品支付金额
            'goodsMoney' => $this->financeModel->getGoodsMoney($startDate, $endDate),
            //当面付支付金额
            //'faceMoney' => $this->financeModel->getFaceMoney($startDate, $endDate),
            //储值支付金额
            'vipMoney' => $this->financeModel->getVipMoney($startDate, $endDate),
            //爆品礼支付金额
            'giftsMoney' => $this->financeModel->getGiftsMoney($startDate, $endDate),
            //实物商品支付
            'getTrueGoodsMoney' => $this->financeModel->getTrueGoodsMoney($startDate, $endDate),
            //虚拟商品支付
            'getFalseGoodsMoney' => $this->financeModel->getFalseGoodsMoney($startDate, $endDate),
            //已打款金额
            'getWithdrawMoney' => $this->financeModel->getWithdrawMoney($startDate, $endDate),
            //收益支付
            'getIncomeMoney' => $this->financeModel->getIncomeMoney($startDate, $endDate),

            //退款金额
            //'backMoney' => $this->financeModel->getBackMoney($startDate, $endDate),
            //秒杀支付金额
            //'seckillMoney' => $this->financeModel->getSeckillMoney($startDate, $endDate),
            //拼团支付金额
            //'teamMoney' => $this->financeModel->getTeamMoney($startDate, $endDate),
            //砍价支付金额
            //'bargainingMoney' => $this->financeModel->getBargainingMoney($startDate, $endDate),
            //零钱总金额
            'smallChange' => $this->financeModel->getSmallChange($startDate, $endDate),
            //零钱抵扣金额
            'balanceMoney' => $this->financeModel->getBalanceMoney($startDate, $endDate),

        ];
    }





}